﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.WindowsMobile.PocketOutlook;

namespace Cryptophone2
{
    public partial class VoiceCall : Form
    {
        public VoiceCall(String number)
        {
            InitializeComponent();

            String contactName = "";
            int idx = number.IndexOf(" <");

            if (idx != -1)
            {
                contactName = number.Substring(0, idx).Trim();
                contactName = contactName.Remove(0, 1);
                contactName = contactName.Remove(contactName.Length - 1, 1);
                number = number.Substring(idx).Trim();
                number = number.Remove(0, 1);
                number = number.Remove(number.Length - 1, 1);
            }
            else
            {
                textBoxName.Visible = false;
            }

            textBoxName.Text = contactName;
            textBoxNumber.Text = number;
        }

        /// <summary>
        /// Accept the incoming call
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void menuItemAccept_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Yes;
            this.Close();
        }

        /// <summary>
        /// Refuse the incoming call
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void menuItemRefuse_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
            this.Close();
        }
    }
}